//1.接口用来定义一个对象的类型
//在定义类型的时候 属性和类型都是固定的
/* interface obj1Type {
  name: string,
  age: number
}

const obj1: obj1Type = {
  name: "laowang",
  age: 18,
} */


//1.
interface obj1Type {
  name: string,
  age: number
}

const obj1: obj1Type = {
  name: "laoliu",
  age: 18
}




//2.可选属性
/* interface obj2Type {
  name: string,
  age: number,
  sex?: any//可选属性
}

const obj2: obj2Type = {
  name: "laowang",
  age: 18,
  sex: "nan"//sex属性可能存在也可能不存在
} */



//2.可选属性
interface obj2Type {
  name: string,
  age: number,
  sex?: any
}

const obj2: obj2Type = {
  name: "laowang",
  age: 19,
  sex: 666
}




//3.对象中有数组
/* type obj3ScoreType = number[];

interface obj3Type {
  name: string,
  age: number,
  score: obj3ScoreType
}

const obj3: obj3Type = {
  name: "laowang",
  age: 18,
  score: [60, 59, 424]
} */


//3.对象中有数组
type obj3ScoreType = (number | string)[]

interface obj3Type {
  name: string,
  age: number,
  score: obj3ScoreType
}

const obj3: obj3Type = {
  name: "laoliu",
  age: 18,
  score: [1, 2, 3, 4, 5, "666"]
}





//4.对象中有对象
/* interface obj4OtherType {
  height: number,
  weight: number,
  girlFri: string[]
}
interface obj4Type {
  name: string,
  age: number,
  other: obj4OtherType
}

const obj4: obj4Type = {
  name: "libo",
  age: 19,
  other: {
    height: 188,
    weight: 188,
    girlFri: ["lily", "lucy", "xiaoming"]
  }
} */


//4.对象中有对象
interface obj4OtherType {
  height: number,
  weight: number,
  girlFri: string[]
}

interface obj4Type {
  name: string,
  age: number,
  other:obj4OtherType
}

const obj4:obj4Type = {
  name: "libo",
  age: 19,
  other: {
    height: 188,
    weight: 188,
    girlFri: ["lily", "lucy", "xiaoming"]
  }
}



//只读属性
/* interface obj5Type {
  name: string,
  //只读属性
  readonly age: number
}

const obj5: obj5Type = {
  name: "laowang",
  age: 18,
}

obj5.age = 19; */



//5.只读
interface obj5Type {
  name: string,
  readonly age: number
}

const obj5:obj5Type = {
  name: "lailiu",
  age: 80
}

obj5.name = "老王"

// obj5.age = 1
